import numpy as np
import matplotlib.pyplot as plt
import os

# define data directory
fname = 'exfig3c.npz'

# load npz file
data = np.load(fname, allow_pickle=True)
print(data.files)
B_up = data['B_up']
B_down = data['B_down']
Ryx_up = data['Ryx_up']
Ryx_down = data['Ryx_down']
B_lin = data['B_lin']
Ryx_asym = data['Ryx_asym']
Temperature = data['Temperature']
indices = data['indices']


# plot raw data
fig, ax = plt.subplots()
fig.suptitle('exfig3c Raw data')
for i in indices:
    ax.plot(B_up[:,i], Ryx_up[:, i], label='T = ' + str(Temperature[i]) + ' K')
    ax.plot(B_down[:,i], Ryx_down[:, i], label='T = ' + str(Temperature[i]) + ' K')
ax.set_xlabel('$B$ (T)')
ax.set_ylabel('$R_{xy}$ raw')
ax.legend()
plt.show()

# plot processed data
fig, ax = plt.subplots()
fig.suptitle('exfig3c antisymmetrized data')
for i in indices:
    ax.plot(B_lin, Ryx_asym[:, i], label='T = ' + str(Temperature[i]) + ' K')
    ax.plot(B_lin, -Ryx_asym[::-1, i], label='T = ' + str(Temperature[i]) + ' K')
ax.set_xlabel('$B$ (T)')
ax.set_ylabel('$R_{yx}$ antisymmetrized')
ax.legend()
plt.show()